<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />


</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left" style="color:#ff4285"></span>
        </a>
        <div class="aui-title" style="color:#ff4285">我的消息</div>

    </header>
    <div class="aui-tab" id="nav">
            <div class="aui-tab-item tapmode aui-active menu"     onclick="fnSetNavMenuIndex(0);">普通消息</div>
            <div class="aui-tab-item tapmode menu"     onclick="fnSetNavMenuIndex(1);">广播消息</div>
        </div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        initEventListenner(); //退出键添加提示框
        fnOpenFrameGroup();//打开FrameGroup
    };

    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWin();
        });
    };
    //打开动画组
    function fnOpenFrameGroup() {
        var frames = [];
        var header = $api.byId('header');
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            style: 'dark',
           color:'transparent'
        });
        var headerH = $api.offset(header).h;
        var nav = $api.byId('nav');
        var navH = $api.offset(nav).h;
        var menus = $api.domAll(nav, '.menu');
        //把一个对象，添加到一个数组中
        for (var i = 0; i < menus.length; i++) {
            frames.push({
                name: 'my_msg_frame' + i,
                url: 'my_msg_frame_' + i + '.html',
                pageParam: {
                    account_details_frame: i
                }
            });
        }
        api.openFrameGroup({
            name: 'myMsgFrameGroup',
            scrollEnabled: true,
            rect: {
                x: 0,
                y: headerH + navH ,
                w: 'auto', //高度宽度，就是拉伸到屏幕右下角
                h: api.winHeight - headerH - navH ,
            },
            index: 0,
            frames: frames
        }, function(ret, err) {
            fnSetNavMenuSelected(ret.index);
        });


    }
    function fnSetNavMenuSelected(index_) {
        var nav = $api.byId('nav');
          var menus = $api.domAll(nav, '.menu');
        for (var i = 0; i < menus.length; i++) {
            if (index_ == i) {
                $api.addCls(menus[i], 'aui-active');
            } else {
                $api.removeCls(menus[i], 'aui-active');
            }
        }
    }
    function fnSetNavMenuIndex(index) {

        fnSetNavMenuSelected(index);
        api.setFrameGroupIndex({
            name: 'myMsgFrameGroup',
            index: index,
            scroll: true
        });
    }

</script>

</html>
